package com.dq.domain.orders;

import com.dq.vo.baseVo.VO;
import com.dq.domain.base.BaseEntity;

import com.dq.domain.org.Org;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import java.math.BigDecimal;

/**
 * @创建人 gewenzhen
 * @创建时间 2019/9/17
 * @描述
 */
@Data
@Entity
@ApiModel("订单")
public class Orders extends BaseEntity implements VO.ToVO {

    @ApiModelProperty("门店")
    @ManyToOne
    public Org org;

    @ApiModelProperty("订单号")
    protected String ordersNo;

    @ApiModelProperty("金额, 放到 orders 中")
    protected BigDecimal price;

    @ApiModelProperty("付款时间")
    protected Long paySuccessTime;
    @ApiModelProperty("交易完成时间")
    protected Long tradeSuccessTime;
    @ApiModelProperty("备注")
    protected String remark;
    @ApiModelProperty("订单超时时间")
    protected Long ordersPayCountDownTime;
    @ApiModelProperty("服务项目和次数")
    protected String serviceProject;
    @ApiModelProperty("是否分配")
    protected Boolean isDistribution;

    @Data
    @ApiModel("订单视图")
    public static class Vo implements VO {

    }

    public Orders(String ordersNo, String remark, Org org, Long ordersPayCountDownTime) {
        this.ordersPayCountDownTime = ordersPayCountDownTime;
        this.ordersNo = ordersNo;
        this.remark = remark;
        this.org = org;
    }

    public Orders(String ordersNo, String remark, Org org, Long ordersPayCountDownTime,BigDecimal price) {
        this.ordersPayCountDownTime = ordersPayCountDownTime;
        this.ordersNo = ordersNo;
        this.remark = remark;
        this.org = org;
        this.price = price;
    }

    public Orders() {
    }

    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();

        return vo;
    }
    public static Long getOrdersPayCountDownTime(Long expressTime) {
        return System.currentTimeMillis() + expressTime * 60 * 1000;
    }
}
